package com.atguigu.gulimall.product.service.impl;

import com.atguigu.gulimall.product.entity.MshoppingcartEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.gulimall.product.dao.MordersDao;
import com.atguigu.gulimall.product.entity.MordersEntity;
import com.atguigu.gulimall.product.service.MordersService;
import org.springframework.util.StringUtils;


@Service("mordersService")
public class MordersServiceImpl extends ServiceImpl<MordersDao, MordersEntity> implements MordersService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        QueryWrapper<MordersEntity> mordersEntityQueryWrapper = new QueryWrapper<MordersEntity>();
        if(!StringUtils.isEmpty(key)){
            mordersEntityQueryWrapper.eq("order_id",key).or().eq("id",key);
        }

        IPage<MordersEntity> page = this.page(
                new Query<MordersEntity>().getPage(params),
                new QueryWrapper<MordersEntity>()
        );

        return new PageUtils(page);
    }

}